Resource Owner Password Credentials Grant
#OAuth
Clientは、Resource OwnerのID/PasswordをAuthorization Serverに渡して、Access Tokenを得る。
ClientがResource OwnerのID/Passwordを知ってしまう。
悪意があればなりすましできる
ClientとAuthorization Serverの持ち主が同じならまあ・・・
公式Clientだったら許容できるでしょう。
Refresh Tokenは使っても良いので、それを保存しておけばID/Passwordを保存する必要はなくなる。
https://plantuml-proxy.vercel.app/svg/https://scrapbox.io/api/code/arai-ta/Resource_Owner_Password_Credentials_Grant/seq.uml#.svg
code:seq.uml
@startuml
box Client side
actor "Resource owner" as Owner
end box
box Server side
participant Client
participant "Authorization Server" as AuthZ
participant "Resource Server" as R
end box
activate Owner
Owner -> Client : Request
activate Client
Client -> Client : リソース使いたいな〜
Client -> Client : パスワードはもらってるしな〜
group OAuth Resource Owner Password Credentials Grant
Client -> AuthZ : POST /oauth/token \n\
Authorization: Basic (clientId, clientSecret) \n\
username=USERNAME&password=PASSWORD
note right: 生のidとパスワードをそのまま渡しちゃう!
activate AuthZ
Client <- AuthZ :access tokenどうぞ
deactivate AuthZ
end
Client -> R : GET /resource \nAuthorization: Bearer access token
activate R
Client <- R : リソースどうぞ
deactivate R
Client -> Client : リソースを使っていろいろできるぞ〜
Owner <- Client : Response
deactivate Client
@enduml